package com.jmu.medicineknows.controller;

import com.jmu.medicineknows.dto.SaleRecordsDto;
import com.jmu.medicineknows.entity.Result;
import com.jmu.medicineknows.entity.SaleRecord;
import com.jmu.medicineknows.entity.ShoppingCart;
import com.jmu.medicineknows.service.SaleRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ACER
 */
@Slf4j
@RestController
@RequestMapping("/saleRecord")
public class SaleRecordController {
    @Resource
    private SaleRecordService saleRecordService;

    @PostMapping("/save")
    public Result orderAdd(@RequestBody SaleRecord saleRecord){
        log.info("sale = " + saleRecord);
        return saleRecordService.orderAdd(saleRecord);
    }
    @PostMapping("/cart")
    public Result addToCart(@RequestBody ShoppingCart shoppingCart){
        log.info("sale = " + shoppingCart);
        return saleRecordService.addToCart(shoppingCart);
    }

    @PostMapping("/list")
    public Result getRecords(@RequestBody SaleRecordsDto SaleRecordsDto){
        log.info("sale = " + SaleRecordsDto);
        return saleRecordService.getRecords(SaleRecordsDto);
    }

    @PostMapping("/countPay")
    public Result countPay(@RequestBody SaleRecordsDto SaleRecordsDto){
        log.info("sale = " + SaleRecordsDto);
        return saleRecordService.countPay(SaleRecordsDto);
    }
}
